<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        "use strict";
        var name = 'fog';
        function gretting(...args){ // rest运算符
            console.log(args,arguments[0],arguments[1]);
            console.log([...arguments],Array.from(arguments)); // 展开运算符
            return `hello,I am ${this.name}`;
        }
        const letter = {
            name: 'letter'
        }
        console.log(gretting.call(letter,18,'china'));
        // console.log(gretting.apply(letter,[18,'china']));
        // 严格模式下下面几个报错
        // console.log(gretting.call());
        // console.log(gretting.call(null));
        // console.log(gretting.call(undefined));

        // 返回了一个this被绑定为letter的函数
        const fn = gretting.bind(letter,18,'china');
        console.log(fn);
        setTimeout(() => {
            fn();
        },1000)
    </script>
</body>
</html>